/**
 * Copyright © 2016-2025 The Thingsboard Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
@import "../../../../scss/constants";

$containerHeight: 96px !default;

:host {
  .tb-container {
    margin-top: 0;
    padding: 0 0 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    label.tb-title {
      display: block;
      padding-bottom: 0;
    }
  }

  .tb-image-select-container {
    width: 100%;
    height: $containerHeight;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    display: flex;
    align-items: center;
    &.disabled {
      width: $containerHeight;
      .tb-image-container {
        width: $containerHeight - 2px;
        border-right: none;
      }
    }
  }

  .tb-image-container {
    width: $containerHeight - 1px;
    height: $containerHeight - 2px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    border-right: 1px solid rgba(0, 0, 0, 0.12);
    background: #fff;
    overflow: hidden;
  }

  .tb-image-preview {
    width: auto;
    max-width: $containerHeight - 2px;
    height: auto;
    max-height: $containerHeight  - 2px;
  }

  .tb-no-image {
    text-align: center;
    color: rgba(0, 0, 0, 0.38);
    font-size: 12px;
    font-style: normal;
    font-weight: 400;
    line-height: 16px;
    letter-spacing: 0.4px;
  }

  .tb-image-info-container {
    display: flex;
    flex: 1;
    align-self: stretch;
    padding: 0 8px;
    justify-content: flex-end;
    align-items: center;
    gap: 4px;
    .tb-base64-image-container, .tb-resource-image-container, .tb-external-image-container {
      display: flex;
      flex: 1;
      align-self: stretch;
    }
    .tb-resource-image-container {
      padding: 8px;
      justify-content: center;
      align-items: flex-start;
      flex-direction: column;
      gap: 4px;
      .tb-resource-image-name {
        color: rgba(0, 0, 0, 0.54);
        overflow: hidden;
        text-overflow: ellipsis;
        word-break: break-all;
        -webkit-line-clamp: 2;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        font-size: 12px;
        font-style: normal;
        font-weight: 500;
        line-height: 16px;
        letter-spacing: 0.25px;
      }
      .tb-resource-image-details {
        display: flex;
        align-items: center;
        gap: 8px;
        color: rgba(0, 0, 0, 0.38);
        font-size: 11px;
        font-style: normal;
        font-weight: 400;
        line-height: 16px;
        letter-spacing: 0.017px;
        .mat-divider.mat-divider-vertical {
          height: 16px;
        }
      }
      &.loading {
        align-items: center;
      }
    }

    .tb-external-image-container {
      padding: 16px 8px 0 16px;
      flex-direction: column;
      align-items: flex-start;
      gap: 4px;
      .tb-external-link-label {
        color: rgba(0, 0, 0, 0.54);
        font-size: 12px;
        font-style: normal;
        font-weight: 400;
        line-height: 16px;
        letter-spacing: 0.4px;
      }
      .tb-external-link-input-container {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        gap: 4px;
        align-self: stretch;
        .tb-inline-field {
          width: 100%;
        }
      }
    }

    .tb-image-clear-btn {
      color: rgba(0,0,0,0.38);
    }
  }

  .tb-image-select-buttons-container {
    display: flex;
    flex: 1;
    align-self: stretch;
    padding: 8px;
    gap: 8px;
    justify-content: center;
    align-items: flex-start;
    .tb-image-select-button {
      width: 100%;
      height: 100%;
      align-self: stretch;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      gap: 4px;
      padding: 8px;
      line-height: normal;
      font-size: 12px;
      @media #{$mat-gt-xs} {
        padding: 16px;
      }
      .mat-icon {
        width: 24px;
        height: 24px;
        font-size: 24px;
        margin: 0;
      }
    }
  }
}
